'use strict';

describe('test new rules directive', function() {
  var $compile, $scope;
  var element;

  beforeEach(module('fbdApp.uploadModule'));

  beforeEach(module('templates'));

  beforeEach(inject(function(_$compile_, _$rootScope_) {
    $compile = _$compile_;
    $scope = _$rootScope_.$new();
    element = $compile("<upload-file></upload-file>")($scope);
    $scope.$digest();
  }));

  it('default value and attributes', function(done) {
    expect(element.find('ng-form').attr('name')).toBe('upload');
    expect(element.find('input').length).toBe(1);
    expect(element.find('input').attr('type')).toBe('file');
    expect(element.find('input').attr('accept')).toBe('.fbd');
    expect(element.find('button').length).toBe(1);
    expect(element.find('button').text()).toBe('确定上传');

    expect(element.find('ng-form').hasClass('ng-invalid')).toBe(true);
    expect(element.find('input').hasClass('ng-invalid-required')).toBe(
      true);
    expect(element.find('button').prop('disabled')).toBe(true);

    return done();
  });
  //
  // it('after upload file', function(done) {
  //   // 怎么模拟上传了文件
  //   $scope.fbdFile = {
  //     name: 'a.fbd',
  //     size: 111,
  //     lostModified: 1467597451000,
  //     type: ''
  //   };
  //
  //   $scope.$digest();
  //   // expect(element.find('form').hasClass('ng-valid')).toBe(true);
  //   // expect(element.find('input').hasClass('ng-valid-required')).toBe(
  //   // true);
  //   // expect(element.find('button').prop('disabled')).toBe(false);
  //   return done();
  // });


});
